/***************************************************************************
 *            simple_sphere.c
 *
 *  Sun Sep  7 18:21:32 2008
 *  Copyright  2008  Tiago Falcão
 *  <tiago@tiagofalcao.com>
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
#include "obj_simple.h"

//Display de Esfera
void obj_simple_sphere_display(void * obj,bool flat,GLuint texture){
	obj_simple_sphere * s=(obj_simple_sphere *)obj;
	if(texture){ 
		glBindTexture(GL_TEXTURE_2D, texture);
		glEnable(GL_TEXTURE_2D);
		
		glEnable(GL_TEXTURE_GEN_S);
		glEnable(GL_TEXTURE_GEN_T);
	}
	if(flat)
		glShadeModel(GL_FLAT);
	glutSolidSphere(s->radius,s->slices,s->stacks);
	if(flat)
		glShadeModel(GL_SMOOTH);
	if(texture){
		glDisable(GL_TEXTURE_2D);
		glDisable(GL_TEXTURE_GEN_S);
		glDisable(GL_TEXTURE_GEN_T);
	}
}

//Display de Cubo
void obj_simple_cube_display(void * obj,bool flat,GLuint texture){
	GLfloat * s=(GLfloat *)obj;
	if(texture){
		glBindTexture(GL_TEXTURE_2D, texture);
		glEnable(GL_TEXTURE_2D);
		glEnable(GL_TEXTURE_GEN_S);
		glEnable(GL_TEXTURE_GEN_T);

	}
	if(flat)
		glShadeModel(GL_FLAT);
	glutSolidCube(*s);
	if(flat)
		glShadeModel(GL_SMOOTH);
	if(texture){
		glDisable(GL_TEXTURE_2D);
		glDisable(GL_TEXTURE_GEN_S);
		glDisable(GL_TEXTURE_GEN_T);;
	}
}
 
//Display de Chaleira
void obj_simple_teapot_display(void * obj,bool flat,GLuint texture){
	GLfloat * s=(GLfloat *)obj;
	if(texture){
		glEnable(GL_TEXTURE_2D); 
		glBindTexture(GL_TEXTURE_2D, texture);
	}
	if(flat)
		glShadeModel(GL_FLAT);
	glutSolidTeapot(*s);
	if(flat)
		glShadeModel(GL_SMOOTH);
	if(texture){
		glDisable(GL_TEXTURE_2D);
	}
}
